<?php
/**
 * Created by PhpStorm.
 * Author: sitenv@aliyun.com
 * CreateTime: 2023/8/20 21:43
 * Blog：www.myblogs.xyz
 */

namespace app\domain\service;

use app\infrastructure\model\UserModel;

class OrderDomainService
{
    // 计算折扣
    public static function integralDiscount(
        int $userId,
        float $orderAmount
    ): float {
        $user = new UserModel();
        $integral = $user->getIntegral($userId);
        $money = bcdiv($integral, 10, 2);
        if ($money < $orderAmount) {
            return $money;
        }
        return $orderAmount;
    }
}